﻿<html>

	<head>
		<title></title>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<link rel="stylesheet" href="../../css/skin/default/style.css" type="text/css" />
		<link rel="stylesheet" href="../../css/dialog.css">
		<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
		<script src="../../js/lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>

		<script src="../../js/lib/ligerUI/js/plugins/ligerPopupEdit.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerMenu.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>

		<script src="../../js/lib/jquery.form.js" type="text/javascript"></script>
		<script src="../../js/lib/json2.js" type="text/javascript"></script>
		<script src="../../js/dialog.js"></script>
		<script src="../../js/constants.js" type="text/javascript"></script>
		<script src="../../js/api.js" type="text/javascript"></script>

		<script type="text/javascript">
			var manager;
			$(document).hover(parent.hindMenu);

			var sid;
			var mid = $api.getparastr("mid");
			var token = $api.getStorage("token");

			function add() {
				window.location.href = 'Add.html';
			}

			$(function() {
				$("form").ligerForm();
				var url = BaseUrl + "SysStore?token=" + token + "&key=";

				toolbar();
				manager = $("#maingrid4").ligerGrid({
					columns: [{
							display: '供应商名称',
							name: 'Ftitle',
							align: 'left',
							width: 360,
							render: function(rowdata, rowindex, value) {
								var ret = "<img src=" + rowdata.Flogo + " class='listimgs' style='float:left;top:5px' />";
								ret += "<div style='margin-left:5px'><p>" + rowdata.Ftitle + "</p>";
								ret += "<p>编码:" + rowdata.Fstorecode + "</p>";
								ret += "<div>"
								return ret;
							}
						},
						{
							display: '联系方式',
							name: 'Fcontact',
							width: 180,
							isSort: true,
							render: function(rowdata, rowindex, value) {
								var ret = rowdata.Fcontact + "[" + rowdata.Fmobile + "]";
								return ret;
							}
						},
						{
							display: '登录账户',
							name: 'Floginname',
							width: 120 
						},
						{
							display: '登录用户',
							name: 'Fusername',
							width: 120 
						},
						{
							display: '状态',
							isSort: true,
							name: 'Fstatus', 
							width: 120,
							align: 'center',
							render: function(rowdata, rowindex, value) {
								  if(rowdata.Fstatus==1)return "正常";
								  return "冻结";
							}
						},
						{
							display: '管理',
							isSort: true,
							name: 'handle',
							minWidth: 180,
							align: 'left',
							render: function(item, rowindex, value) {
								return "<a class='listbtn' style='margin-top:15px;margin-left:5px;width:60px;'  onclick='addUser(" + rowindex + ");'>设置用户</a>" +
//									"<a class='listbtn' style='margin-top:15px;margin-left:5px;width:60px'  onclick='setStoreConfig(" + rowindex + ");'>店铺配置</a>" +
//									"<a class='listbtn' style='margin-top:15px;margin-left:5px;width:60px '  onclick='setWxConfig(" + rowindex + ");'>小程序配置</a>" +
									"<a class='listbtn' style='margin-top:15px;margin-left:5px;width:60px'  onclick='delStore(" + rowindex + ");'>删除</a>";;
							}
						}
					],
					url: url,
					method: 'get',
					width: '99.5%',
					height: '92%',
					dataAction: 'local',
					isScroll: true,
					rowHeight: 100,
					pageSize: 10,
					usePager: true,
					onDblClickRow: function(data, rowindex, rowobj) {
						window.location.href = 'Add.html?Fid=' + data.Fid;
					}
				});

			});

			function edit() {
				var manager = $("#maingrid4").ligerGetGridManager();
				var row = manager.getSelectedRow();
				if(row) {
					window.location.href = 'Add.html?Fid=' + row.Fid;
				} else {
					$.ligerDialog.warn("请选择行");
				}
			}

			function toolbar() {
				//获取附加权限
				$api.getLimit(mid, 1, function(data) {
					$("#icon-list").append(data);
				});
			}

			function doSearch() {
				var key = $("#txtKeywords").val();
				var url = BaseUrl + "SysStore?token=" + token + "&key=" + key;
				manager.GetDataByURL(url);
			}

			function f_reload() {
				manager.loadData(true);
			};

//			function setStoreConfig(rowindex) {
//				var manager = $("#maingrid4").ligerGetGridManager();
//				var row = manager.getRow(rowindex);
//				window.location.href = "../../vcommon/sys_config/StoreConfig.html?Fsid=" + row.Fid + "&Fname=" + escape(row.Ftitle);
//			}
//
//			function setWxConfig(rowindex) {
//				var manager = $("#maingrid4").ligerGetGridManager();
//				var row = manager.getRow(rowindex);
//				window.location.href = "../../vcommon/sys_config/WxConfig.html?Fsid=" + row.Fid + "&Fname=" + escape(row.Ftitle);
//			}

			function addUser(rowindex) {
				var manager = $("#maingrid4").ligerGetGridManager();
				var row = manager.getRow(rowindex);
				var url = "vsys/tb_store_user/add.html?Fsid=" + row.Fid + "&Fname=" + escape(row.Ftitle);
				parent.openCommWindow(url, '设置供应商用户', 600, 480, "addUser");
			}
	 
			function saveInfo(row, cmd) {
				if(cmd == "addUser") {
					
					var url = BaseUrl + "SysOperator?token=" + token + "&action=" + row.action;
					$api.ajax2(url, row.data, function(data) {
						top.$.ligerDialog.succ("设置用户成功！");
						f_reload();
					});

				}
			}

			function delStore(rowindex) {
				var manager = $("#maingrid4").ligerGetGridManager();
				var row = manager.getRow(rowindex);
				del2(row);
			}

			function del() {
				var manager = $("#maingrid4").ligerGetGridManager();
				var row = manager.getSelectedRow();
				del2(row);
			}

			function del2(row) {

				if(row) {
					$.ligerDialog.confirm("信息删除后不能恢复，\n您确定要移除？", function(yes) {
						if(yes) {
							var url = BaseUrl + "SysStore?action=del&token=" + token;
							$api.ajax2(url, row, function(data) {

								f_reload();
							});
						}
					})
				} else {
					$.ligerDialog.warn("请选择行！");
				}
			}

			function f_save(item, dialog) {
				var param = dialog.frame.f_save();
				if(param) {
					dialog.close();
					var url = BaseUrl + "SysStore?action=add&token=" + token;
					$api.ajax2(url, data, function(data) {

						f_reload();
					});

				}
			}
		</script>

	</head>

	<body class="mainbody">
		<form id="form1" onsubmit="return false">
			<div style="display:none" class="div-alarm"></div>
			<div class="toolbar-wrap">
				<div  class="toolbar">
					<div class="l-list">
						<ul id="icon-list" class="icon-list">
						</ul>
					</div>
					<div class="r-list">
						<input type="text" ID="txtKeywords" placeholder='名称/编码/联系方式' class="keyword" />
						<a class='btn-search' onclick='doSearch();' style="margin-right:10px;">搜索</a>

					</div>
				</div>
			</div>

			<div id="maingrid4" style="margin: 0px;background:#fff;"></div>

		</form>

	</body>

</html>